<?php
header('Content-type: text/html; charset=UTF-8');
$isAdmin = $this->Session->Read('user.level')=='1'?true:false;
?>
<div class="companies index">
	<h2><?php __('Companies');?></h2>
	<table cellpadding="0" cellspacing="0">
	<tr>
			<th><?php echo $this->Paginator->sort('social_reason');?></th>
			<th><?php echo $this->Paginator->sort('cnpj');?></th>
			<?php /*?>
			<th><?php echo $this->Paginator->sort('address');?></th>
			<th><?php echo $this->Paginator->sort('neighborhood');?></th>
			<th><?php echo $this->Paginator->sort('city');?></th>
			<th><?php echo $this->Paginator->sort('cep');?></th>
			<th><?php echo $this->Paginator->sort('rh_contact');?></th>
			<th><?php echo $this->Paginator->sort('law_11_788');?></th>
			<th><?php echo $this->Paginator->sort('available');?></th>
			<?php */?>
		<th class="actions" style="text-align: center;"><?php __('Actions');?>
		</th>
	</tr>
	<?php
	$i = 0;
	foreach ($companies as $company):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
		<td><?php echo $company['Company']['social_reason']; ?>&nbsp;</td>
		<td><?php echo $company['Company']['cnpj']; ?>&nbsp;</td>
		<?php /*?>
		<td><?php echo $company['Company']['address']; ?>&nbsp;</td>
		<td><?php echo $company['Company']['neighborhood']; ?>&nbsp;</td>
		<td><?php echo $company['Company']['city']; ?>&nbsp;</td>
		<td><?php echo $company['Company']['cep']; ?>&nbsp;</td>
		<td><?php echo $company['Company']['rh_contact']; ?>&nbsp;</td>
		<td><?php echo $company['Company']['law_11_788']; ?>&nbsp;</td>
		<td><?php echo $company['Company']['available']; ?>&nbsp;</td>
		<?php */?>
		<td class="actions">
			<?php echo $this->Html->link(__('View', true), array('action' => 'view', $company['Company']['id'])); ?>
			<?php if($isAdmin):?>
				<?php echo $this->Html->link(__('Edit', true), array('action' => 'edit', $company['Company']['id'])); ?>
				<?php
				if($isAdmin)
					echo $this->Html->link(__('Delete', true), array('action' => 'delete', $company['Company']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $company['Company']['id'])); ?>
			<?php endif;?>
			
		</td>
	</tr>
<?php endforeach; ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
	));
	?>	</p>

	<div class="paging">
		<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	</div>
</div>
<div class="actions">
	<h3><?php __('Actions'); ?></h3>
	<ul>
		<li><?php echo $this->Html->link(__('New Company', true), array('action' => 'add')); ?></li>
		<li><?php echo $this->Html->link(__('Logout', true), array('controller'=>'users', 'action' => 'logout')); ?></li>
	</ul>
</div>